Skip to content

Require ASCII digits in French department numbers - #577

Open
itzzdev09 wants to merge 1 commit into
python-validators:masterfrom
itzzdev09:fix/fr-department-ascii-digits
Open

itzzdev09 wants to merge 1 commit into
python-validators:masterfrom
itzzdev09:fix/fr-department-ascii-digits

Conversation

@itzzdev09

Copy link
Copy Markdown
Contributor

fr_department() converts string input with int(), which also accepts surrounding whitespace, a leading sign, underscores and any Unicode decimal digit (docs). These all validate on master:

>>> validators.fr_department(" 75")
True
>>> validators.fr_department("75\n")
True
>>> validators.fr_department("+75")
True
>>> validators.fr_department("7_5")
True
>>> validators.fr_department("75")  # fullwidth 75
True
>>> validators.fr_department("٧٥")  # Arabic-Indic 75
True

#532 required ASCII digits in fr_ssn() and the other regional identifiers; this does the same for fr_department() by matching the string against [0-9]+ before converting it. Integer input and the 2A/2B Corsica codes are unchanged.

The six values above are added to the invalid-department cases in tests/i18n/test_fr.py; they fail without the change. tests/i18n/test_fr.py passes (44 passed), as does the rest of the suite apart from the eth_address tests, which need the optional eth-hash dependency not installed here. ruff check and ruff format --check pass.

fr_department() converted string input with int(), which also accepts
surrounding whitespace, a sign, underscores and non-ASCII decimal digits,
so values such as " 75", "+75", "7_5" or fullwidth "75" validated.
Match the string against [0-9]+ before converting it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant